//package com.nomichat.basemodule.application
//
//import android.content.Context
//import android.os.Bundle
//import android.os.Handler
//import android.os.Looper
//import android.view.MotionEvent
//import android.view.View
//import android.view.inputmethod.InputMethodManager
//import android.widget.EditText
//import androidx.fragment.app.FragmentActivity
//import com.alibaba.android.arouter.launcher.ARouter
//import com.nomichat.basemodule.widget.MCTitlebar
//
///**
// * @Desc base
// * @Author macjay
// * @Time 2022/12/15 16:27
// */
//abstract class VBBaseActivity : FragmentActivity() {
//    private lateinit var viewBinding: VBBaseActivity
//    val mHandler: Handler by lazy { Handler(Looper.getMainLooper()) }
//    lateinit var titleBar: MCTitlebar
//   // private var mProgressDialog: MCProgressDialog? = null
//
////    override fun attachBaseContext(newBase: Context?) {
////        super.attachBaseContext(newBase?.let { LanguageUtils.attach(newBase) })
////    }
//
//    override fun onCreate(savedInstanceState: Bundle?) {
//        super.onCreate(savedInstanceState)
//        ARouter.getInstance().inject(this)
//
//
//
//        viewBinding = VbBaseActivityBinding.inflate(layoutInflater)
//        setContentView(viewBinding.root)
//        initView()
//    }
//
//    abstract fun getContent(): View
//
//    private fun initView() {
//        titleBar = viewBinding.baseTitlebar
//        viewBinding.baseFlContent.addView(getContent())
//        if (hideTitleBar()) {
//            viewBinding.baseTitlebar.visibility = View.GONE
//        }
//    }
//
//    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
//        if (ev?.action == MotionEvent.ACTION_DOWN) {
//            val view = currentFocus
//            if (isShouldHideKeyboard(view, ev) && shouldHide()) {
//                view?.windowToken?.let {
//                    val im = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
//                    im.hideSoftInputFromWindow(it, InputMethodManager.HIDE_NOT_ALWAYS)
//                }
//            }
//        }
//        return super.dispatchTouchEvent(ev)
//    }
//
//    open fun shouldHide(): Boolean {
//        return true
//    }
//
//    private fun isShouldHideKeyboard(v: View?, event: MotionEvent): Boolean {
//        if (v != null && v is EditText) {
//            val l = intArrayOf(0, 0)
//            v.getLocationInWindow(l)
//            val left = l[0]
//            val top = l[1]
//            val bottom = top + v.getHeight()
//            val right = left + v.getWidth()
//            return !(event.x > left && event.x < right && event.y > top && event.y < bottom)
//        }
//        // 如果焦点不是EditText则忽略，这个发生在视图刚绘制完，第一个焦点不在EditText上，和用户用轨迹球选择其他的焦点
//        return false
//    }
////
////    fun showProgress() {
////        if (mProgressDialog?.isResumed == true) {
////            mProgressDialog?.dismissAllowingStateLoss()
////            mProgressDialog = null
////        }
////        try {
////            mProgressDialog = MCProgressDialog()
////            mProgressDialog?.showNow(supportFragmentManager, "progressDialog")
////        } catch (_: Exception) {
////        }
////    }
////
////    fun dismissProgress() {
////        if (mProgressDialog == null) return
////        if (mProgressDialog!!.isAdded) {
////            mProgressDialog?.dismissAllowingStateLoss()
////            mProgressDialog = null
////        }
////    }
//
//    open fun hideTitleBar(): Boolean {
//        return false
//    }
//}